var data=angular.module("myApp")
 //价钱区间过滤
 var str="4000-4999";

data.controller("HouseController",["$scope", "HouseService",function($scope,HouseService){
         HouseService.getData().success(function(res){     
            $scope.items = res.data.rows;
           // console.log(res.data.rows);
        });

        //点击出现标签选择页
        $scope.IdData=1;
        $scope.fgIndex = function(e){
            $scope.IdData=e.target.id;
            $scope.isShownav=true;
          //  console.log($scope.IdData);
            //if($scope.IdData==$scope.IdData){
            e.target.setAttribute("class","active");
            //}
        }
        /*标签类型切换*/
        $scope.states = "";
        $scope.IdData=1;
		$scope.fg = function(index,e){
			$scope.IdData=e.target.id;
			//console.log($scope.IdData);		
			if($scope.states!=null){
				$scope.states.className="";
			};
			e.target.setAttribute("class","active");
				$scope.states = e.target;
                console.log($scope.IdData);
		}

        

        //位置,类型,其他 过滤
		$scope.states2="";
		$scope.add = function(e){  
			if($scope.states2!=null){
				$scope.states2.className="";
			};
			e.target.setAttribute("class","active");
			$scope.states2 = e.target;
            $scope.isShownav=false;
            str=e.target.innerHTML;
            console.log(e.target.innerHTML)
            
            if(e.target.innerHTML=="不限"){
                $scope.searchKey == "";
            } else {
                $scope.searchKey = e.target.innerHTML;
            }
		}

	//house轮播图
     var mySwiper = new Swiper ('.swiper-container', {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        direction: 'horizontal',
        autoplay : 3000,
        speed:300,
        loop: true,
        
        // 如果需要分页器
        pagination: '.swiper-pagination',
        
      })   

     // var str=["0-100","4000-4999",""]
   
   // $scope.De="0000";
    //  $scope.mayfilter = function(obj){

    //     var splitD=$scope.str.split(/\-/);
    //     var listData=[];
    //     for(var i in obj){
    //         if ((parseInt(splitD[0]) <= parseInt(obj.jprice)) && (parseInt(obj.jprice)<=parseInt(splitD[1]))) {

    //             console.log(obj.id);
    //             listData.push(obj);
    //          }
    //     }
    //     return listData;
    // }
}]);

data.filter('myfilter',function(){
    return function(obj){
    if (obj==undefined) {
        return;
    }
  
    var splitD=str.split(/\-/);
        var listData=[];
        for (var i = 0; i < obj.length; i++) {
             if ((parseInt(splitD[0]) <= parseInt(obj[i].jprice)) && (parseInt(obj[i].jprice)<=parseInt(splitD[1]))) {
                 listData.push(obj[i]);
             }
        };
        return listData;
    }
}) 
  